import { defHttp } from '@/utils/request';

// 全局信息---无需登录   (app初始化时候需要加载.)
export function getConfigApi() {
  return defHttp.get({
    url: '/api/index/config',
  });
}

// 分享---分享码页面---查询当前是否有进行中的分享码
export function checkRedeemedShareCodeApi() {
  return defHttp.get({
    url: '/api/index/share',
  });
}

export function checkPickedUpShareCodeApi() {
  return defHttp.get({
    url: '/api/index/sharelist',
  });
}

// 分享---分享码页面-点击申请
export function applyShareCodeApi() {
  return defHttp.get({
    url: '/api/index/doshare',
  });
}

// 分享---分享码页面-抽奖(非主页抽奖)
export function shareCodeLotteryDrawApi(data) {
  return defHttp.post({
    url: '/api/index/sharedraw',
    data,
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  });
}
// 更新个人信息
// name   收货人姓名
// mobile   收货人手机号
// p_id 省
// c_id 市ID
// d_id 区ID
// s_id 街道ID
// area 详细地址 (字符串)
export function updateProfileInfoApi() {
  return defHttp.post({
    url: '/api/index/updateaddress',
  });
}

export function inviteRedeemedShareCodeApi(data) {
  return defHttp.post({
    url: '/api/index/invite',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
    data,
  });
}

export function helpShareApi(data) {
  return defHttp.post({
    url: '/api/index/help',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
    data,
  });
}
//奖品列表
export function getPrizeListApi() {
  return defHttp.get({
    url: '/api/prize/index',
  });
}
//我的奖品
export function getMyPrizeListApi() {
  return defHttp.get({
    url: '/api/prize/my',
  });
}
//购买
export function buyPrizeApi(data) {
  return defHttp.post({
    url: '/api/prize/buy',
    data,
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  });
}
//用户中心
export function getUserInfoApi() {
  return defHttp.get({
    url: '/api/user/index',
  });
}
//兑换
export function exchangePrizeApi(data) {
  return defHttp.post({
    url: '/api/prize/change ',
    data,
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  });
}
//全部订单
export function getAllOrderApi() {
  return defHttp.get({
    url: '/api/order/my',
  });
}
//待发货
export function getWaitOrderApi() {
  return defHttp.get({
    url: '/api/order/pendding',
  });
}
//待收货
export function getReceiveOrderApi() {
  return defHttp.get({
    url: '/api/order/delivery',
  });
}
//获取省
export function getProvinceApi() {
  return defHttp.get({
    url: '/region/getProvince',
  });
}
//获取市
export function getCityApi(data) {
  return defHttp.post({
    url: '/region/getCity',
    data,
  });
}
//获取区
export function getDistrictApi(data) {
  return defHttp.post({
    url: '/region/getDistrict',
    data,
  });
}
//获取街道
export function getStreetApi(data) {
  return defHttp.post({
    url: '/region/getStreet',
    data,
  });
}
//新增收货地址
export function addAddressApi(data) {
  return defHttp.post({
    url: '/api/address/create',
    data,
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  });
}
//我的收货地址
export function getAddressApi() {
  return defHttp.get({
    url: '/api/address/my',
  });
}
//删除收货地址
export function deleteAddressApi(data) {
  return defHttp.post({
    url: '/api/address/delete',
    data,
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  });
}
//更新收货地址
export function updateAddressApi(data) {
  return defHttp.post({
    url: '/api/address/update',
    data,
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  });
}
//提醒发货
export function orderNoticeApi(data) {
  return defHttp.post({
    url: '/api/order/notice',
    data,
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  });
}
//提货
export function orderPickupApi(data) {
  return defHttp.post({
    url: '/api/order/send',
    data,
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  });
}
//主页抽奖
export function drawApi() {
  return defHttp.get({
    url: '/api/draw/index',
  });
}
//设置为默认收货地址
export function setDefaultAddressApi(data) {
  return defHttp.post({
    url: '/api/address/set',
    data,
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
    },
  });
}
